

import Vue from "vue"
import VueRouter from "vue-router"

// 0
Vue.use(VueRouter);   // use 全局注册一个vue模块

// 1. 路由组件
import Main from "@/views/Main.vue"
import List from "@/views/List.vue"


// 2. 路由配置
const routes = [
    {
        path:"/main",
        name:'main',
        component:Main
    },
    {
        path:"/list",
        name:'list',
        component:List
    },
    {
        path:"/find",
        name:'find',
        component:()=>import("@/views/Find.vue"), // 路由懒加载  当前路由激活的时候才去加载进入组件 
    },
    {
        path:"/mine",
        name:"mine",
        component:()=>import("@/views/Mine.vue")   // 路由懒加载  
    },
    {
        path:"/vuex",
        name:"vuex",
        component:()=>import("@/views/Vuex.vue")   // 路由懒加载  
    },
    {
        path:"*",
        redirect:{
            name:"main"
        }
    }
]

// 3.创建路由
const router = new VueRouter({
    routes,
    mode:"history",
    base:""
})

// 4. 挂载到根实例 
export default router 